import Vue from 'vue'
import Router from 'vue-router'
import userLogin from '@/components/userLogin'
import siteList from '@/components/siteList'
import applyList from '@/components/applyList'
Vue.use(Router)

// eslint-disable-next-line no-unused-vars
let router;
// eslint-disable-next-line no-unused-vars
export default router = new Router({
    routes: [
        {
            path: '/userLogin',
            name: 'userLogin',
            component: userLogin
        },
        {
            path: '/siteList',
            name: 'siteList',
            component: siteList
        },
        {
            path: '/applyList',
            name: 'applyList',
            component: applyList
        }
    ]
})
router.beforeEach((to, from, next) => {
    if(to.path=="/userLogin"){
        return next();
    }
    var tokenStr=window.sessionStorage.getItem("token");
    if(!tokenStr){
        return next("/userLogin");
    }
    next();
});